/*
========================================================================
 Name        : TestUiAppUi.cpp
 Author      : iTest2008
 Copyright   : iTest2008
 Description : 
========================================================================
*/
// [[[ begin generated region: do not modify [Generated System Includes]
#include <eikmenub.h>
#include <akncontext.h>
#include <akntitle.h>
#include <TestUi.rsg>
// ]]] end generated region [Generated System Includes]

// [[[ begin generated region: do not modify [Generated User Includes]
#include "TestUiAppUi.h"
#include "TestUi.hrh"
#include "TestUiContainerView.h"
// ]]] end generated region [Generated User Includes]
#include "ui\TestMe2AppView.h"
#include "ui\cpainter.h"
// [[[ begin generated region: do not modify [Generated Constants]
// ]]] end generated region [Generated Constants]

/**
 * Construct the CTestUiAppUi instance
 */ 
CTestUiAppUi::CTestUiAppUi()
	{
	// [[[ begin generated region: do not modify [Generated Contents]
	// ]]] end generated region [Generated Contents]
	iAppView = NULL;
	}

/** 
 * The appui's destructor removes the container from the control
 * stack and destroys it.
 */
CTestUiAppUi::~CTestUiAppUi()
	{
	// [[[ begin generated region: do not modify [Generated Contents]
	// ]]] end generated region [Generated Contents]
	if(iAppView)
	{
		delete iAppView;
		iAppView = NULL;
	}
	if(iPainter)
		delete iPainter;	
	}

// [[[ begin generated function: do not modify
void CTestUiAppUi::InitializeContainersL()
	{
	iTestUiContainerView = CTestUiContainerView::NewL();
	AddViewL( iTestUiContainerView );
	SetDefaultViewL( *iTestUiContainerView );
	}
// ]]] end generated function

/**
 * Handle a command for this appui (override)
 * @param aCommand command id to be handled
 */
void CTestUiAppUi::HandleCommandL( TInt aCommand )
	{
	// [[[ begin generated region: do not modify [Generated Code]
	TBool commandHandled = EFalse;
	switch ( aCommand )
		{ // code to dispatch to the AppUi's menu and CBA commands is generated here
		default:
			break;
		}
	
		
	if ( !commandHandled ) 
		{
		if ( aCommand == EAknSoftkeyExit || aCommand == EEikCmdExit)
			Exit();
		}
	// ]]] end generated region [Generated Code]
	
	}

/** 
 * Override of the HandleResourceChangeL virtual function
 */
void CTestUiAppUi::HandleResourceChangeL( TInt aType )
	{
	CAknViewAppUi::HandleResourceChangeL( aType );
	// [[[ begin generated region: do not modify [Generated Code]
	// ]]] end generated region [Generated Code]
	
	}
				
/** 
 * Override of the HandleKeyEventL virtual function
 * @return EKeyWasConsumed if event was handled, EKeyWasNotConsumed if not
 * @param aKeyEvent 
 * @param aType 
 */
TKeyResponse CTestUiAppUi::HandleKeyEventL(
		const TKeyEvent& aKeyEvent,
		TEventCode aType )
	{
	// The inherited HandleKeyEventL is private and cannot be called
	// [[[ begin generated region: do not modify [Generated Contents]
	// ]]] end generated region [Generated Contents]
	
	return EKeyWasNotConsumed;
	}

/** 
 * Override of the HandleViewDeactivation virtual function
 *
 * @param aViewIdToBeDeactivated 
 * @param aNewlyActivatedViewId 
 */
void CTestUiAppUi::HandleViewDeactivation( 
		const TVwsViewId& aViewIdToBeDeactivated, 
		const TVwsViewId &aNewlyActivatedViewId )
	{
	CAknViewAppUi::HandleViewDeactivation( aViewIdToBeDeactivated, aNewlyActivatedViewId );
	// [[[ begin generated region: do not modify [Generated Contents]
	// ]]] end generated region [Generated Contents]
	
	}

/**
 * @brief Completes the second phase of Symbian object construction. 
 * Put initialization code that could leave here. 
 */ 
void CTestUiAppUi::ConstructL()
	{
	// [[[ begin generated region: do not modify [Generated Contents]
	BaseConstructL( EAknEnableSkin );
	InitializeContainersL();
	// ]]] end generated region [Generated Contents]
	//在获取"矩形区域"后设置status pane、Cba为不见
//	CEikStatusPane* statusp = StatusPane();
//	if(statusp)
//	  statusp->MakeVisible(EFalse);

	iPainter = new CPainter();
	iPainter->LoadFileL(_L("c:\\images\\bk.gif"));
	
	}

void CTestUiAppUi::TestMe()
{
	if(iAppView == NULL)
	{
		iAppView = MyMenuBar::NewL( iPainter, TRect(0,257,240,287) );	
		//AddToStackL( iAppView );		
	}
	
	
	///iAppView->SetMopParent( iTestUiContainerView );
}

void CTestUiAppUi::TestMe2()
{
	iAppView->TestMe();	
}